package com.example.yiwei.crm.view.Class.listviewClass;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.example.yiwei.crm.R;
import com.example.yiwei.crm.entity.UserCarCustomerEntity;

import java.util.List;

/**
 * Created by Administrator on 2018/1/24.
 */

public class ListViewSelectAdapter extends BaseAdapter {

    private List<UserCarCustomerEntity> list;
    private Context context;
    private LayoutInflater mInflater;
    public ListViewSelectAdapter(List<UserCarCustomerEntity>list, Context context){
        this.list = list;
        this.context = context;
        mInflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView ==null){
            convertView = mInflater.inflate(R.layout.layout_list_select,parent,false);
            holder = new ViewHolder();
            holder.tv_name = (TextView) convertView.findViewById(R.id.text_name);
            holder.tv_address = (TextView) convertView.findViewById(R.id.text_address);
            holder.tv_time = (TextView) convertView.findViewById(R.id.text_time);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv_name.setText(list.get(position).getName());
        holder.tv_address.setText(list.get(position).getAddress());
        holder.tv_time.setText(list.get(position).getTime());
        return convertView;
    }
    private class ViewHolder{
        TextView tv_name,tv_address,tv_time;
    }
}
